// 设备操作界面
#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>

#include "loginwidget.h"
#include "databasemanager.h"
#include <QSqlRelationalTableModel>

#include <QMainWindow>
#include <QSqlDatabase>
#include <QSqlTableModel>

namespace Ui {
class mainWidget;
}

class mainWidget : public QWidget
{
    Q_OBJECT

public:
    explicit mainWidget(QWidget *parent = nullptr);
    ~mainWidget();

private slots:

    //日志管理
    void on_btn_shangyiye_rizhi_2_clicked();
    void on_btn_xiayiye_rizhi_2_clicked();


    // 串口管理
    void on_btnSave_clicked();
    void on_btnAdd_clicked();

    void on_label_yema_rizhi_2_linkActivated(const QString &link);

    void on_btn_baocun_yonghu_2_clicked();

    void on_btn_zengjia_yonghu_2_clicked();

    void on_btn_shanchu_yonghu_2_clicked();

    void on_btn_chaxun_yonghu_2_clicked();

private:
    Ui::mainWidget *ui;

    int currentPage = 1;
    const int pageSize = 8;

    QSqlQueryModel *serialportSqlQueryModel;
    QSqlRelationalTableModel *serialportModel;

    loginWidget* m_loginWidget;

    QStringList logLines; // 存储所有日志记录
    void updatePageLabel();
    void displayLogPage();

    int selectionColumnCount;

    QSqlDatabase db;
    QSqlTableModel *model;

    QSqlRelationalTableModel *stuModel;
};

#endif // MAINWIDGET_H
